package com.hnyfkj.jyindustry.biz.xiaofei.controller;

import java.util.Arrays;
import java.util.List;


import com.hnyfkj.jyindustry.biz.xiaofei.dto.XiaofeiLogInsertDto;
import com.hnyfkj.jyindustry.biz.xiaofei.dto.XiaofeiLogQueryDto;
import com.hnyfkj.jyindustry.biz.xiaofei.dto.XiaofeiLogUpdateDto;
import com.hnyfkj.jyindustry.biz.xiaofei.entity.XiaofeiLog;
import com.hnyfkj.jyindustry.biz.xiaofei.service.XiaofeiLogService;
import com.hnyfkj.jyindustry.common.dto.PageReturnDto;
import com.hnyfkj.jyindustry.common.dto.RespDto;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.ui.Model;



/**
 * 理发店------消费记录
 *
 * @author zhangzhang
 * @email 15838129129@163.com
 * @date 2021-04-18 16:08:50
 */
@Controller
@RequestMapping("xiaofeilog")
public class XiaofeiLogController {
    @Autowired
    private XiaofeiLogService xiaofeiLogService;



    /**
	 * 添加页面
	 */
    @GetMapping("/add")
    public String addPage() {
        return "xiaofeilog/xiaofeilog-add";
    }

    /**
     * 编辑页面
     */
    @GetMapping("/edit")
    public String editPage(@RequestParam("id") String id, Model model) {
        XiaofeiLog xiaofeiLog = xiaofeiLogService.getById(id);
        model.addAttribute("xiaofeiLog", xiaofeiLog);
        return "xiaofeilog/xiaofeilog-edit";
    }

    /**
     * 列表页面
     */
    @GetMapping("/listPage")
    public String listPage(@RequestParam("id") String id, Model model) {

        //List<XiaofeiLog> xiaofeiLog=xiaofeiLogService.findXiaoFei(id);
        model.addAttribute("id",id);
        return "xiaofeilog/xiaofeilog-table";
    }
    /**
     * 列表
     */
    @RequestMapping("/list")
    @ResponseBody
    public RespDto<PageReturnDto<XiaofeiLog>> list(@RequestBody XiaofeiLogQueryDto queryDto){
        return RespDto.succResult(xiaofeiLogService.queryPage(queryDto));
    }
    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("barbar:xiaofeilog:info")
    public RespDto<XiaofeiLog> info(@PathVariable("id") Integer id){
		XiaofeiLog xiaofeiLog = xiaofeiLogService.getById(id);
        return RespDto.succResult(xiaofeiLog);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("barbar:xiaofeilog:save")
    public RespDto<String> save(@RequestBody XiaofeiLogInsertDto xiaofeiLogInsertDto){
        xiaofeiLogService.insert(xiaofeiLogInsertDto);
        return RespDto.succ();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("barbar:xiaofeilog:update")
    public RespDto<String> update(@RequestBody XiaofeiLogUpdateDto xiaofeiLogupdateDto){
        xiaofeiLogService.update(xiaofeiLogupdateDto);
        return RespDto.succ();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("barbar:xiaofeilog:delete")
    public RespDto<String> delete(@RequestBody Integer[] ids){
		xiaofeiLogService.removeByIds(Arrays.asList(ids));
        return RespDto.succ();
    }

}
